{#include main}
{#title}Indexed Entities{/title}
{#body}
{#if info:indexedPersistenceUnits.persistenceUnits.isEmpty}
<p>No indexed entities were found.</p>
{#else}
<form method="post" enctype="application/x-www-form-urlencoded">
    <input id="index" type="submit" class="btn btn-primary mb-2" value="Reindex Entities">
    <br/>
    {#for indexedPersistenceUnit in info:indexedPersistenceUnits.persistenceUnits}
    <h4><span class="badge">Persistence Unit</span> <i class="badge badge-info">{indexedPersistenceUnit.persistenceUnitName}</i></h4>
    <table id="table" class="table table-striped">
        <colgroup>
            <col span="1" style="width: 5%;">
            <col span="1" style="width: 30%;">
            <col span="1" style="width: 65%;">
        </colgroup>
        <thead class="thead-dark">
        <tr>
            <th scope="col">
                <div class="custom-control">
                    <input type="checkbox" class="form-check-input" onChange="handleSelectAll(this)">
                </div>
            </th>
            <th scope="col">Entity name</th>
            <th scope="col">Entity type</th>
        </tr>
        </thead>
        <tbody>
        {#for indexedEntityType in indexedPersistenceUnit.indexedEntities}
        <tr>
            <td>
                <div class="custom-control">
                    <input type="checkbox" class="form-check-input checkbox" name="{indexedEntityType.jpaName}"
                           id="{indexedEntityType.jpaName}" value="{indexedPersistenceUnit.persistenceUnitName}">
                </div>
            </td>
            <td>{indexedEntityType.jpaName}</td>
            <td>{indexedEntityType.javaClass}</td>
        </tr>
        {/for}
        </tbody>
    </table>
    {/for}
</form>
<script type="text/javascript">
    function handleSelectAll(elem) {
        $(elem).parents('table:first').find('.checkbox').prop('checked', elem.checked);
    }

</script>
{/if}
{/body}
{/include}
